package com.example.zrq1010110087.implicit_intent;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.PhoneNumberUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


    private EditText phonenumber_et;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        phonenumber_et=(EditText)findViewById(R.id.phonenumber);
    }

    public void button(View v){
        String  iphoneNumber=phonenumber_et.getText().toString().trim();
        if(PhoneNumberUtils.isGlobalPhoneNumber(iphoneNumber)){

            Intent intent=new Intent(Intent.ACTION_CALL, Uri.parse("tel://"+iphoneNumber));
          startActivity(intent);


        }else {
            Toast.makeText(MainActivity.this,"please input phoneNumber!",Toast.LENGTH_SHORT).show();

        }

    }
}
